CPPFLAGS += $(addprefix -I,$(includedirs))
CXXFLAGS += -std=gnu++0x
LDFLAGS += $(addprefix -L,$(libdirs)) $(addprefix -l,$(links))

objects += $(addsuffix .o, $(basename $(sources)))

ifneq (,$(pchsource))
	sources := $(filter-out $(pchsource),$(sources))
endif
ifneq (,$(pchheader))
    pchobject := $(pchheader).gch
endif

all: $(pchobject) $(program) $(static)
$(pchobject) : $(pchheader)
$(program) : $(objects)
	$(CXX) -o $(program) $(objects) $(LDFLAGS)
$(static) : $(pchheader) $(objects)
	$(AR) -cr $@ $?
$(objects) : %.o : %.cpp
	$(CXX) -o $@ -c $< $(CPPFLAGS) $(CXXFLAGS) -MMD
#$(pchheader) : %.cpp

-include $(addsuffix .d,$(basename $(sources)))

#clean:
#   rm -f $(objects)
